package com.example.excelimport.controller;

import com.example.excelimport.utils.PoiUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: mainController
 * @DESCRIPT: TODO
 * @AUTHOR: cuizhichao
 * @DATA: 2020/1/14 11:03 AM
 **/
@RestController
public class mainController {

    @PostMapping(value = "import")
    public Map<String,Object> importExcel(MultipartFile file){
        Map<String,Object> result = new HashMap<>();
        try {
            result = PoiUtil.readExcel("/validateresource.xml",0,file);
        } catch (IOException e) {
            result.put("ret","-1");
            result.put("data",e.getMessage());
        }
        return result;
    }
}
